package com.springvn.sample.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.genericdao.search.ISearch;
import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;
import com.springvn.sample.dao.IEmployeeDAO2;
import com.springvn.sample.persistence.Employee2;
import com.springvn.sample.services.IEmployeeService2;

@Service
@Transactional
public class EmployeeService2 implements IEmployeeService2 {

	@Autowired
	private IEmployeeDAO2 employeeDao;

	@Override
	public void addEmployee(Employee2 entity) {
		this.employeeDao.save(entity);

	}

	@Override
	public List<Employee2> getAllEmployees() {
		return this.employeeDao.findAll();
	}

	@Override
	public void deleteEmployee(Integer employeeId) {
		this.employeeDao.removeById(employeeId);

	}

	@Override
	public List<Employee2> search(ISearch search) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public SearchResult<Employee2> searchAndCount(ISearch search) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Employee2 findById(Integer id) {
		// TODO Auto-generated method stub
		return employeeDao.find(id);
	}

	@Override
	public Employee2 findByName(String name) {
		// TODO Auto-generated method stub
//		return employeeDao.searchUnique(new Search()
//		.addFilterEqual("name",name)
//		.addFetch("citizens"));
		return null;
	}

	@Override
	public void flush() {
		// TODO Auto-generated method stub

	}

}
